package com.shu.driftbook.service;

import java.util.ArrayList;
import java.util.List;

import com.shu.driftbook.dao.Book;
import com.shu.driftbook.dao.DriftQueueDao;

public class DriftQueueServiceImpl implements DriftQueueService{
	private DriftQueueDao drift_queue_dao;

	public DriftQueueDao getDrift_queue_dao() {
		return drift_queue_dao;
	}

	public void setDrift_queue_dao(DriftQueueDao drift_queue_dao) {
		this.drift_queue_dao = drift_queue_dao;
	}

	@Override
	public long findUsedUser(Integer bookid) {
		// TODO Auto-generated method stub
		return drift_queue_dao.findUsedUser(bookid);
	}

	@Override
	public long findWaitingUser(Integer bookid) {
		// TODO Auto-generated method stub
		return drift_queue_dao.findWaitingUser(bookid);
	}

	@Override
	public List<Reader> findReader(List<Book> result) {
		// TODO Auto-generated method stub
		List<Reader> reader=new ArrayList<Reader>();
		Reader numofreader;
			for(int i=0;i<result.size();i++){
				long count1=findUsedUser(result.get(i).getBookid());
				long count2=findWaitingUser(result.get(i).getBookid());
				numofreader=new Reader(count1,count2);
				reader.add(numofreader);
			}
		return reader;
	}
}
